class Solution:
    def findPeakElement(self, nums):
        """
        :type nums: []
        """

        if not nums or len(nums) == 1:
            return 0
        
        if nums[1] < nums[0]:
            return 0
        if nums[-1] > nums[-2]:
            return len(nums)-1
        for i in range(1, len(nums)-1):
            if nums[i] > nums[i-1] and nums[i] > nums[i+1]:
                return i

if __name__ == '__main__':
    print Solution().findPeakElement([1, 2, 3, 1])

